<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>setOverlayColor</title>
</head>
<body>
  <canvas id="canvasBox" width="800" height="800" style="border: 1px solid #ccc;"></canvas>

  <script src="../../script/fabric.js"></script>
  <script>
    let canvas = new fabric.Canvas('canvasBox')


    // 设置纯色
    // canvas.setOverlayColor('yellowgreen', canvas.renderAll.bind(canvas))

    // 设置纯色
    // canvas.setOverlayColor('pink', function() {
    //   console.log('完成')
    //   canvas.renderAll()
    // })


    // 设置背景图
    // 默认会重复渲染
    canvas.setOverlayColor({
      source: '../../images/bg4.png'
    }, canvas.renderAll.bind(canvas))

    // canvas.setOverlayColor({
    //   source: '../../images/bg4.png',
    //   repeat: 'no-repeat', // 不重复
    //   offsetX: 200, // x轴方向的偏移
    //   offsetY: 100 // y轴方向的偏移
    // }, canvas.renderAll.bind(canvas))
  </script>
</body>
</html>